package com.lxmap;

import javax.swing.text.html.HTMLDocument;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;

public class hashmapdemo {
    public static void main(String[] args) {
        //三种遍历hashmap的方式
        Map<String,String> m = new HashMap<>();
        m.put("lll","xxx");
        m.put("aaa","bbb");
        m.put("kkk","vvv");
        Set<String> key = m.keySet();
//        for (String s : key) {
//            System.out.println(m.get(s));
//        }
//        Iterator<String> it = key.iterator();
//        while(it.hasNext())
//        {
//            System.out.println(m.get(it.next()));
//        }
        key.forEach(new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(m.get(s));
            }
        });
    }
}
